﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeTester
{
    class FibonacciRecursively
    {
        public long Fibonacci(uint n)
        {
            if(n<=0)
            {
                return 0;
            }
            if(n==1)
            {
                return 1;
            }

            return Fibonacci(n - 1) + Fibonacci(n - 2);
        }

        public long FibonacciNew(uint n)
        {
            if (n <= 1)
            {
                return n;
            }

            long na = 0;
            long nb = 1;
            long fibN = 0;
            for(int i=2;i<= n;i++)
            {
                fibN = na + nb;

                na = nb;
                nb = fibN;
            }

            return fibN;
            
        }
    }
}
